<!--# layout("/common/layout.html",{"jsBase":"/js/content/ebookUpdateRecord/"}){ -->

<form class="layui-form layui-form-pane" id="addForm"  lay-filter="editform">
    <input type="hidden" name="id" id="id">
    <input type="hidden" name="bookId" id="bookId" value="${bookId}">
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">标题</label>
				<div class="layui-input-inline">
                      <input type="text" name="title" id="title" autocomplete="off" maxlength="50" class="layui-input" >
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <layui:singleFile id="url" tagName="下载地址" tips=""/>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">可用标记</label>
				<div class="layui-input-inline">
                                <input type="radio" name="status" value="1" title="是" checked>
                                <input type="radio" name="status" value="0" title="否">
				</div>
            </div>
        </div>
    </div>


    <layui:submitButtons id="addButton" />
</form>
<!--#} -->
<script>
layui.extend({
    loading: '../../../plugins/layui_extends/loading/loading',
}).define([ 'form', 'laydate', 'table','loading','ebookUpdateRecordApi'], function(exports) {
    var form = layui.form;
    var ebookUpdateRecordApi = layui.ebookUpdateRecordApi;
    var index = layui.index;
    var isNew = true;
    <!--# if(!(isEmpty(ebookUpdateRecordJson))){  -->
    isNew = false;
    <!--# } -->
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                // $("#addButton").hide();
                // $("#addButton-loading").show();
                // $("#addButton-loading").loading();
                form.on('submit(form)', function(){
                    ebookUpdateRecordApi.saveForm(isNew,$('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("保存成功");
                        Lib.closeFrame();
                    });
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    view.init();
    <!--# if(!(isEmpty(ebookUpdateRecordJson))){  -->
    var formJson = ${ebookUpdateRecordJson};
    form.val("editform",formJson);
    $(".file_link").each(function() {
        var a=document.createElement('a');
        var aJq = $(a);
        aJq.html("下载文件");
        aJq.attr("href",formJson[$(this).attr("id")]);
        aJq.attr("target","_blank");
        $(this).append(aJq);
    });
    <!--# } -->
});
</script>
